package com.qc31.monitorlib.ui.listmonitor

import com.qc31.baselib.utils.CacheMMKV


/** @Author Jasper @Time 2020/11/13 @Desc 列表监控参数设置 */
class ListMonitorModel {
    companion object {
        val instance: ListMonitorModel by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
            ListMonitorModel()
        }
    }

    private var isTimeShow: Boolean
    private var isStateShow: Boolean
    private var isSpeedShow: Boolean
    private var isDriverShow: Boolean
    private var isMileShow: Boolean
    private var isRunStopShow: Boolean

    init {
        isTimeShow = CacheMMKV.decodeBoolean("isTimeShow", true)
        isStateShow = CacheMMKV.decodeBoolean("isStateShow", true)
        isSpeedShow = CacheMMKV.decodeBoolean("isSpeedShow", true)
        isDriverShow = CacheMMKV.decodeBoolean("isDriverShow", true)
        isMileShow = CacheMMKV.decodeBoolean("isMileShow", true)
        isRunStopShow = CacheMMKV.decodeBoolean("isRunStopShow", true)
    }

    fun getTimeShow(): Boolean = isTimeShow
    fun getStateShow(): Boolean = isStateShow
    fun getSpeedShow(): Boolean = isSpeedShow
    fun getDriverShow(): Boolean = isDriverShow
    fun getMileShow(): Boolean = isMileShow
    fun getRunStopShow(): Boolean = isRunStopShow

    fun setTime(isTimeShow: Boolean) {
        this.isTimeShow = isTimeShow
        CacheMMKV.encode("isTimeShow", isTimeShow)
    }

    fun setState(isStateShow: Boolean) {
        this.isStateShow = isStateShow
        CacheMMKV.encode("isStateShow", isStateShow)
    }

    fun setSpeed(isSpeedShow: Boolean) {
        this.isSpeedShow = isSpeedShow
        CacheMMKV.encode("isSpeedShow", isSpeedShow)
    }

    fun setDriver(isDriverShow: Boolean) {
        this.isDriverShow = isDriverShow
        CacheMMKV.encode("isDriverShow", isDriverShow)
    }

    fun setMile(isMileShow: Boolean) {
        this.isMileShow = isMileShow
        CacheMMKV.encode("isMileShow", isMileShow)
    }

    fun setRunStop(isRunStopShow: Boolean) {
        this.isRunStopShow = isRunStopShow
        CacheMMKV.encode("isRunStopShow", isRunStopShow)
    }

}